require 'oauth'
require 'oauth/consumer'
require 'oauth/token'
class MyToken < ActiveRecord::Base
  
  def self.consumer 
    OAuth::Consumer.new SERVICE_CONFIG['consumer_key'], 
                  SERVICE_CONFIG['consumer_secret'],
                  {:site=>SERVICE_CONFIG['site'], :request_token_path=>SERVICE_CONFIG['request_token_url'], :access_token_path=>SERVICE_CONFIG['access_token_url'], :authorize_path=>SERVICE_CONFIG['authorization_url']}
  end
  
  def self.whisper_consumer
    OAuth::Consumer.new SERVICE_CONFIG['consumer_key'], 
                  SERVICE_CONFIG['consumer_secret'],
                  {:site=>SERVICE_CONFIG['whisper_url']}
  end
  
  def as_request_token
    OAuth::RequestToken.new(MyToken.consumer,self.key, self.secret)
  end
  def as_access_token
    OAuth::AccessToken.new(MyToken.whisper_consumer,self.key, self.secret)
  end
end
